<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Document</title>
    </head>
    <body>
        <div id="test"></div>

        <script src="https://unpkg.com/react@16/umd/react.development.js"></script>
		<script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
		<!-- 生产环境中不建议使用 -->
		<script src="https://unpkg.com/babel-standalone@6.15.0/babel.min.js"></script>
        <script type="text/babel">
            // 创建组件
            class Login extends React.Component{
                handleSubmit = (event)=>{
                    event.preventDefault();// 取消默认事件  w3c的方法是e.preventDefault()，IE则是使用e.returnValue = false;
                    console.log(this);
                    const {username,password} = this;
                    // 页面表单中输入类DOM的值,现用现取  就是非受控组件
                    alert("账号:"+username.value+",密码:"+password.value+"")
                }
                render(){
                    return(
                        <form action="https://www.baidu.com" onSubmit={this.handleSubmit}>
                            账号:<input ref={(c)=>{this.username = c}} type="text" name="username"/>
                            密码:<input ref={(c)=>{this.password = c}} type="password" name="password"/>
                            <button>登陆</button>
                        </form>
                    )
                }
            }
            ReactDOM.render(<Login/>,document.getElementById("test"));
        </script>
    </body>
</html>